package com.xm.service.background;


import com.xm.dao.background.WarehouseDao;
import com.xm.entity.CommodityWarehouse;
import com.xm.entity.Page;
import com.xm.entity.Warehouse;
import com.xm.exception.SqlErrorException;

import java.util.List;


/**
 * @author 田顺琪
 * @date 2024-01-02
 */
public class WarehouseService {
    private final WarehouseDao dao = new WarehouseDao();

    /**
     * 查询全部Message
     * @return List集合
     */
    public Page<CommodityWarehouse> getCondition(int pageNumber,int pageSize,int id,String commodityMc) {
        return dao.getCondition(pageNumber,pageSize,id,commodityMc);
    }

    /**
     *
     * @param pageNumber 当前页码
     * @param pageSize 每页显示数量
     * @param warehouseMc 搜索名称
     * @return 成功返回true，失败返回false
     */
    public Page<Warehouse> pagination(int pageNumber, int pageSize,String warehouseMc) {
        return dao.pagination(pageNumber,pageSize,warehouseMc);
    }

    /**
     *
     * @param inventory 库存
     * @param limit 限购
     * @param commodityId 商品编号
     * @return 成功返回true，失败返回false
     * @throws SqlErrorException SQL执行异常
     */
    public boolean reviseCommodityWarehouse(int inventory,int limit,int commodityId) throws SqlErrorException {
        return dao.update(inventory,limit,commodityId);
    }
    /**
     * 根据仓库ID查询仓库信息
     * @param warehouseId 仓库ID
     * @return Warehouse对象
     */
    public Warehouse getWarehouseById(int warehouseId) {
        return dao.getWarehouseById(warehouseId);
    }
    /**
     * 查询除指定仓库ID以外的所有仓库信息
     * @param excludeId 需要排除的仓库ID
     * @return List<Warehouse>对象
     */
    public List<Warehouse> getAllWarehousesExcept(int excludeId) {
        return dao.getAllWarehousesExcept(excludeId);
    }
}
